using System.Collections;
using DG.Tweening;
using UnityEngine;

public class PlayerState_死亡 : PlayerStateBase
{
	private Color _color_影子;

	private Coroutine _Cor_死亡;

	public override void OnEnter()
	{
		_Mono._Is死亡 = true;
		GameManager._CanPlay = false;
		_color_影子 = _Mono._SR_影子.color;
		_Cor_死亡 = _Mono.StartCoroutine(Cor_死亡());
	}

	private IEnumerator Cor_死亡()
	{
		_Mono._Ani.Play("死亡前跳跃");
		_Mono._Rb2D.velocity = 30f * new Vector2(_Mono.transform.position.x - _Mono._BeAttack_Pos.x, 0f).normalized;
		_Mono.transform.localScale = new Vector3((_Mono._BeAttack_Pos.x > _Mono.transform.position.x) ? 1 : (-1), 1f, 1f);
		MonoSingleton<AudioManager>.Instance.F_Play_SFX(_Mono._AudioC_死亡);
		yield return new WaitForSeconds(0.5f);
		_Mono._Rb2D.bodyType = RigidbodyType2D.Kinematic;
		_Mono._Rb2D.velocity = Vector2.zero;
		_Mono._Ani.Play("倒地");
		yield return new WaitForSeconds(1.5f);
		_Mono._SR_Model.DOFade(0f, 2f);
		_Mono._SR_影子.DOFade(0f, 2f);
		yield return new WaitForSeconds(1.5f);
		_Cor_死亡 = null;
		MonoSingleton<GameManager>.Instance.F_上香(上香: false);
	}

	public override void OnExit()
	{
		if (_Cor_死亡 != null)
		{
			_Mono.StopCoroutine(_Cor_死亡);
		}
		_Mono._SR_Model.DOKill();
		_Mono._SR_影子.DOKill();
		_Mono._Rb2D.bodyType = RigidbodyType2D.Dynamic;
		_Mono._SR_Model.color = new Color(1f, 1f, 1f, 1f);
		_Mono._SR_影子.color = _color_影子;
	}

	public override void OnUpdate()
	{
	}
}
